# -*- coding: utf-8 *-*
import json
from src.helper.path import PathHelper


class LoaderConfig:

    def __init__(self):
        pass

    @staticmethod
    def load(path):
        maindir = PathHelper.getMainDirectory()
        path = maindir + path
        return json.loads(open(path, 'r').read())
        
    @staticmethod
    def save(relativePath, data):
        maindir = PathHelper.getMainDirectory()
        path = maindir + relativePath
        print(path)
        file = open(path, 'w')
        if isinstance(data, str):
            file.write(data)
            file.close()
            return json.loads(data)
        else:
            file.write(json.dumps(data))
            file.close()
            return data
       
